import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const moduleA = {
  state:{
    name:'wangzhen'
  },
  actions:{
    aaaa({state,commit,rootState}){

    }
  },
  mutations:{},
  getters:{
    ggggg({state,commit,rootState}){

    }
  }
}

const store = new Vuex.Store({
  state:{
    counter:1000
  },
  mutations:{
    increment(state,n){
      state.counter++
    },
    decrement(state){
      state.counter--
    },
    addCount(state,count){
      console.log(count)
      state.counter += count
    }
  },
  actions:{
    aincrement(context){
      setTimeout(()=>{
        context.commit('increment')
      },1000)
    },
    aaddCount(context,payload){
      return new Promise((resolve,reject)=>{
        setTimeout(()=>{
          //context.commit('addCount',payload)
          console.log(payload)
          resolve('处理完返回的参数')
        },1000)
      })
    }
  },
  getters:{
    newcouter(state){
      return state.counter*10
    }
  },
  modules:{
    a:moduleA
  }
})

export default store